home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / edit / thesrc20.zip / commsos.c < prev    next >
C/C++ Source or Header  |  1995-01-26  |  83KB  |  2,702 lines

  1. /***********************************************************************/
  2. /* COMMSOS.C - sos commands.                                           */
  3. /* This file contains all commands that can be assigned to function    */
  4. /* keys or typed on the command line.                                  */
  5. /***********************************************************************/
  6. /*
  7.  * THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
  8.  * Copyright (C) 1991-1995 Mark Hessling
  9.  *
  10.  * This program is free software; you can redistribute it and/or
  11.  * modify it under the terms of the GNU General Public License as
  12.  * published by the Free Software Foundation; either version 2 of
  13.  * the License, or any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18.  * General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to:
  22.  *
  23.  *    The Free Software Foundation, Inc.
  24.  *    675 Mass Ave,
  25.  *    Cambridge, MA 02139 USA.
  26.  *
  27.  *
  28.  * If you make modifications to this software that you feel increases
  29.  * it usefulness for the rest of the community, please email the
  30.  * changes, enhancements, bug fixes as well as any and all ideas to me.
  31.  * This software is going to be maintained and enhanced as deemed
  32.  * necessary by the community.
  33.  *
  34.  * Mark Hessling                     email: M.Hessling@gu.edu.au
  35.  * 36 David Road                     Phone: +61 7 849 7731
  36.  * Holland Park                      Fax:   +61 7 875 5314
  37.  * QLD 4121
  38.  * Australia
  39.  */
  40.  
  41. /*
  42. $Id: commsos.c 2.0 1995/01/26 16:30:18 MH Release MH $
  43. */
  44.  
  45. #include <stdio.h>
  46.  
  47. #include "the.h"
  48. #include "proto.h"
  49.  
  50. /*#define DEBUG 1*/
  51.  
  52. /*man-start*********************************************************************
  53.  
  54.  
  55.  
  56. ========================================================================
  57. SOS COMMAND REFERENCE
  58. ========================================================================
  59. **man-end**********************************************************************/
  60.  
  61. /*man-start*********************************************************************
  62. COMMAND
  63.      sos addline - add blank line after focus line
  64.  
  65. SYNTAX
  66.      SOS ADDline
  67.  
  68. DESCRIPTION
  69.      The SOS ADDLINE command inserts a blank line in the file following
  70.      the focus line. The cursor is placed in the column under the first
  71.      non-blank in the focus line.
  72.  
  73. COMPATIBILITY
  74.      XEDIT: Compatible.
  75.      KEDIT: Compatible.
  76.  
  77. SEE ALSO
  78.      SOS LINEADD, SOS DELLINE
  79.  
  80. STATUS
  81.      Complete
  82. **man-end**********************************************************************/
  83. #ifdef PROTO
  84. short Sos_addline(CHARTYPE *params)
  85. #else
  86. short Sos_addline(params)
  87. CHARTYPE *params;
  88. #endif
  89. /***********************************************************************/
  90. {
  91. /*--------------------------- local data ------------------------------*/
  92.  short rc=RC_OK;
  93. /*--------------------------- processing ------------------------------*/
  94. #ifdef TRACE
  95.  trace_function("commsos.c: Sos_addline");
  96. #endif
  97.  rc = Add("1");
  98. #ifdef TRACE
  99.  trace_return();
  100. #endif
  101.  return(rc);
  102. }
  103. /*man-start*********************************************************************
  104. COMMAND
  105.      sos bottomedge - move cursor to bottom edge of FILEAREA
  106.  
  107. SYNTAX
  108.      SOS BOTTOMEdge
  109.  
  110. DESCRIPTION
  111.      The SOS BOTTOMEDGE command moves the cursor to the last 
  112.      enterable line in the FILEAREA or PREFIX area. If the cursor
  113.      is on the command line, the cursor moves to the first 
  114.      enterable line of the FILEAREA.
  115.  
  116. COMPATIBILITY
  117.      XEDIT: N/A
  118.      KEDIT: Comaptible.
  119.  
  120. SEE ALSO
  121.      SOS TOPEDGE
  122.  
  123. STATUS
  124.      Complete.
  125. **man-end**********************************************************************/
  126. #ifdef PROTO
  127. short Sos_bottomedge(CHARTYPE *params)
  128. #else
  129. short Sos_bottomedge(params)
  130. CHARTYPE *params;
  131. #endif
  132. /***********************************************************************/
  133. {
  134. /*-------------------------- external data ----------------------------*/
  135. /*--------------------------- local data ------------------------------*/
  136.  short rc=RC_OK;
  137.  unsigned short y=0,x=0,row=0;
  138. /*--------------------------- processing ------------------------------*/
  139. #ifdef TRACE
  140.  trace_function("commsos.c: Sos_bottomedge");
  141. #endif
  142.  getyx(CURRENT_WINDOW,y,x);
  143. /*---------------------------------------------------------------------*/
  144. /* Get the last enterable row. If an error, stay where we are...       */
  145. /*---------------------------------------------------------------------*/
  146.  if (find_last_focus_line(&row) != RC_OK)
  147.    {
  148. #ifdef TRACE
  149.     trace_return();
  150. #endif
  151.     return(rc);
  152.    }
  153. /*---------------------------------------------------------------------*/
  154. /* For each window determine what needs to be done...                  */
  155. /*---------------------------------------------------------------------*/
  156.  switch(CURRENT_VIEW->current_window)
  157.    {
  158.     case WINDOW_COMMAND:
  159.          if ((CURRENT_VIEW->prefix&PREFIX_LOCATION_MASK) != PREFIX_LEFT)
  160.             x += PREFIX_WIDTH;
  161.          CURRENT_VIEW->focus_line = CURRENT_SCREEN.sl[row].line_number;
  162.          pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  163.          CURRENT_VIEW->current_window = WINDOW_MAIN;
  164.          wmove(CURRENT_WINDOW,row,x);
  165.          break;
  166.     case WINDOW_MAIN:
  167.     case WINDOW_PREFIX:
  168.             if (row != y)                            /* different rows */
  169.               {
  170.                post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  171.                CURRENT_VIEW->focus_line = CURRENT_SCREEN.sl[row].line_number;
  172.                pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  173.                wmove(CURRENT_WINDOW,row,x);
  174.               }
  175.             break;
  176.    }
  177. #ifdef TRACE
  178.  trace_return();
  179. #endif
  180.  return(rc);
  181. }
  182. /*man-start*********************************************************************
  183. COMMAND
  184.      sos current - move cursor to current line
  185.  
  186. SYNTAX
  187.      SOS CURRent
  188.  
  189. DESCRIPTION
  190.      The SOS CURRENT command moves the cursor to the current column
  191.      of the cursor line from any window.
  192.  
  193. COMPATIBILITY
  194.      XEDIT: N/A
  195.      KEDIT: Compatible.
  196.  
  197. STATUS
  198.      Complete
  199. **man-end**********************************************************************/
  200. #ifdef PROTO
  201. short Sos_current(CHARTYPE *params)
  202. #else
  203. short Sos_current(params)
  204. CHARTYPE *params;
  205. #endif
  206. /***********************************************************************/
  207. {
  208. /*-------------------------- external data ----------------------------*/
  209. /*--------------------------- local data ------------------------------*/
  210.  short rc=RC_OK;
  211.  unsigned short x=0,y=0;
  212.  bool same_line=TRUE;
  213. /*--------------------------- processing ------------------------------*/
  214. #ifdef TRACE
  215.  trace_function("commsos.c: Sos_current");
  216. #endif
  217.  getyx(CURRENT_WINDOW_MAIN,y,x);
  218.  switch (CURRENT_VIEW->current_window)
  219.    {
  220.     case WINDOW_MAIN:
  221.          if (CURRENT_VIEW->focus_line != CURRENT_VIEW->current_line)
  222.            {
  223.             post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  224.             CURRENT_VIEW->focus_line = CURRENT_VIEW->current_line;
  225.             same_line = FALSE;
  226.            }
  227.          y = get_row_for_focus_line(CURRENT_VIEW->focus_line,
  228.                                     CURRENT_VIEW->current_row);
  229.          wmove(CURRENT_WINDOW_MAIN,y,x);
  230.          if (!same_line)
  231.             pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  232.          break;
  233.     case WINDOW_PREFIX:
  234.     case WINDOW_COMMAND:
  235.          CURRENT_VIEW->focus_line = CURRENT_VIEW->current_line;
  236.          y = get_row_for_focus_line(CURRENT_VIEW->focus_line,
  237.                                     CURRENT_VIEW->current_row);
  238.          CURRENT_VIEW->current_window = WINDOW_MAIN;
  239.          wmove(CURRENT_WINDOW_MAIN,y,x);
  240.          pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  241.          break;
  242.     default:
  243.          break;
  244.    }
  245. #ifdef TRACE
  246.  trace_return();
  247. #endif
  248.  return(rc);
  249. }
  250. /*man-start*********************************************************************
  251. COMMAND
  252.      sos cursoradj - move first non-blank character to cursor
  253.  
  254. SYNTAX
  255.      SOS CURSORAdj
  256.  
  257. DESCRIPTION
  258.      The SOS CURSORADJ command moves text in the focus line so that
  259.      the first non-blank character appears under the cursor position.
  260.  
  261. COMPATIBILITY
  262.      XEDIT: N/A
  263.      KEDIT: Compatible.
  264.  
  265. STATUS
  266.      Complete
  267. **man-end**********************************************************************/
  268. #ifdef PROTO
  269. short Sos_cursoradj(CHARTYPE *params)
  270. #else
  271. short Sos_cursoradj(params)
  272. CHARTYPE *params;
  273. #endif
  274. /***********************************************************************/
  275. {
  276. /*-------------------------- external data ----------------------------*/
  277.  extern CHARTYPE *rec;
  278. /*--------------------------- local data ------------------------------*/
  279.  short num_cols=0,first_non_blank_col=0,col=0,rc=RC_OK;
  280.  unsigned short x=0,y=0;
  281. /*--------------------------- processing ------------------------------*/
  282. #ifdef TRACE
  283.  trace_function("commsos.c: Sos_cursoradj");
  284. #endif
  285.  getyx(CURRENT_WINDOW,y,x);
  286.  switch (CURRENT_VIEW->current_window)
  287.    {
  288.     case WINDOW_MAIN:
  289.          if (FOCUS_TOF || FOCUS_BOF)
  290.            {
  291.             display_error(38,(CHARTYPE *)"",FALSE);
  292. #ifdef TRACE
  293.             trace_return();
  294. #endif
  295.             return(RC_INVALID_ENVIRON);
  296.            }
  297.          col = x + CURRENT_VIEW->verify_col - 1;
  298.          first_non_blank_col = strzne(rec,' ');
  299.          if (first_non_blank_col == (-1))
  300.             first_non_blank_col = 0;
  301.          num_cols = first_non_blank_col - col;
  302.          if (num_cols < 0)
  303.             rc = execute_shift_command(FALSE,-num_cols,CURRENT_VIEW->focus_line,1,FALSE);
  304.          else
  305.             if (num_cols > 0)
  306.                rc = execute_shift_command(TRUE,num_cols,CURRENT_VIEW->focus_line,1,FALSE);
  307.          break;
  308.     default:
  309.          break;
  310.    }
  311. #ifdef TRACE
  312.  trace_return();
  313. #endif
  314.  return(rc);
  315. }
  316. /*man-start*********************************************************************
  317. COMMAND
  318.      sos delback - delete the character to the left of the cursor
  319.  
  320. SYNTAX
  321.      SOS DELBAck
  322.  
  323. DESCRIPTION
  324.      The SOS DELBACK command moves the cursor one character to the left
  325.      and deletes the character now under the cursor.
  326.  
  327. COMPATIBILITY
  328.      XEDIT: N/A
  329.      KEDIT: Compatible.
  330.  
  331. SEE ALSO
  332.      SOS DELCHAR
  333.  
  334. STATUS
  335.      Complete
  336. **man-end**********************************************************************/
  337. #ifdef PROTO
  338. short Sos_delback(CHARTYPE *params)
  339. #else
  340. short Sos_delback(params)
  341. CHARTYPE *params;
  342. #endif
  343. /***********************************************************************/
  344. {
  345. /*------------------------- external data -----------------------------*/
  346.  extern CHARTYPE *rec;
  347.  extern LENGTHTYPE rec_len;
  348.  extern CHARTYPE *cmd_rec;
  349.  extern unsigned short cmd_rec_len;
  350.  extern CHARTYPE *pre_rec;
  351.  extern unsigned short pre_rec_len;
  352.  extern bool prefix_changed;
  353.  extern bool readonly;
  354.  extern bool CMDARROWSTABLRx;
  355.  extern VIEW_DETAILS *vd_mark;
  356. /*--------------------------- local data ------------------------------*/
  357.  unsigned short x=0,y=0;
  358. /*--------------------------- processing ------------------------------*/
  359. #ifdef TRACE
  360.  trace_function("commsos.c: Sos_delback");
  361. #endif
  362.  getyx(CURRENT_WINDOW,y,x);
  363.  switch (CURRENT_VIEW->current_window)
  364.    {
  365.     case WINDOW_MAIN:
  366. /*---------------------------------------------------------------------*/
  367. /* If running in read-only mode and an attempt is made to execute this */
  368. /* command in the MAIN window, then error...                           */
  369. /*---------------------------------------------------------------------*/
  370.          if (readonly)
  371.            {
  372.             display_error(56,"",FALSE);
  373. #ifdef TRACE
  374.             trace_return();
  375. #endif
  376.             return(RC_INVALID_ENVIRON);
  377.            }
  378.          if (CURRENT_SCREEN.sl[y].line_type != LINE_LINE)
  379.            {
  380.             display_error(38,(CHARTYPE *)"",FALSE);
  381. #ifdef TRACE
  382.             trace_return();
  383. #endif
  384.             return(RC_INVALID_ENVIRON);
  385.            }
  386.          break;
  387.     case WINDOW_COMMAND:
  388.          if (x == 0)
  389.            {
  390. #ifdef TRACE
  391.             trace_return();
  392. #endif
  393.             return(RC_OK);
  394.            }
  395.          wmove(CURRENT_WINDOW,y,x-1);
  396.          my_wdelch(CURRENT_WINDOW);
  397.          if (x <= cmd_rec_len)
  398.            {
  399.             memdelchr(cmd_rec,x-1,cmd_rec_len,1);
  400.             cmd_rec_len--;
  401.            }
  402. #ifdef TRACE
  403.          trace_return();
  404. #endif
  405.          return(RC_OK);
  406.          break;
  407.     case WINDOW_PREFIX:
  408.          if (x == 0)
  409.            {
  410. #ifdef TRACE
  411.             trace_return();
  412. #endif
  413.             return(RC_OK);
  414.            }
  415.          prefix_changed = TRUE;
  416.          wmove(CURRENT_WINDOW,y,x-1);
  417.          my_wdelch(CURRENT_WINDOW);
  418.          if (x <= pre_rec_len)
  419.            {
  420.             memdelchr(pre_rec,x-1,pre_rec_len,1);
  421.             pre_rec_len --;
  422.            }
  423. #ifdef TRACE
  424.             trace_return();
  425. #endif
  426.          return(RC_OK);
  427.          break;
  428.     default:
  429.          break;
  430.    }
  431. /*---------------------------------------------------------------------*/
  432. /* Remainder of processing is only for WINDOW_MAIN.                    */
  433. /*---------------------------------------------------------------------*/
  434.  if (x == 0 && CURRENT_VIEW->verify_start == CURRENT_VIEW->verify_col)
  435.    {
  436. #ifdef TRACE
  437.     trace_return();
  438. #endif
  439.     return(RC_OK);
  440.    }
  441.  cursor_left(TRUE,FALSE);
  442. /*---------------------------------------------------------------------*/
  443. /* If we are after the last character of the line, exit.               */
  444. /*---------------------------------------------------------------------*/
  445.  if (x+CURRENT_VIEW->verify_col-1 > rec_len)
  446.    {
  447. #ifdef TRACE
  448.     trace_return();
  449. #endif
  450.     return(RC_OK);
  451.    }
  452.  
  453.  getyx(CURRENT_WINDOW,y,x);
  454.  my_wdelch(CURRENT_WINDOW);
  455.  
  456.  memdelchr(rec,CURRENT_VIEW->verify_col-1+x,rec_len,1);
  457.  rec_len--;
  458. /*---------------------------------------------------------------------*/
  459. /* If there is a character off the right edge of the screen, display it*/
  460. /* in the last character of the main window.                           */
  461. /*---------------------------------------------------------------------*/
  462.  if (CURRENT_VIEW->verify_col-1+CURRENT_SCREEN.cols[WINDOW_MAIN]-1 < rec_len)
  463.    {
  464.     wmove(CURRENT_WINDOW,y,CURRENT_SCREEN.cols[WINDOW_MAIN]-1);
  465.     put_char(CURRENT_WINDOW,rec[CURRENT_VIEW->verify_col-1+CURRENT_SCREEN.cols[WINDOW_MAIN]-1],ADDCHAR);
  466.     wmove(CURRENT_WINDOW,y,x);
  467.    }
  468. /*---------------------------------------------------------------------*/
  469. /* If the character being deleted is on a line which is in the marked  */
  470. /* block, redisplay the window.                                        */
  471. /*---------------------------------------------------------------------*/
  472.  if (CURRENT_VIEW == MARK_VIEW)
  473.    {
  474.     if (CURRENT_VIEW->focus_line >= MARK_VIEW->mark_start_line
  475.     &&  CURRENT_VIEW->focus_line <= MARK_VIEW->mark_end_line)
  476.       {
  477.        build_current_screen();
  478.        display_current_screen();
  479.       }
  480.    }
  481. #ifdef TRACE
  482.  trace_return();
  483. #endif
  484.  return(RC_OK);
  485. }
  486. /*man-start*********************************************************************
  487. COMMAND
  488.      sos delchar - delete character under cursor
  489.  
  490. SYNTAX
  491.      SOS DELChar
  492.  
  493. DESCRIPTION
  494.      The SOS DELCHAR command deletes the character under the cursor.
  495.      Text to the right is shifted to the left.
  496.  
  497. COMPATIBILITY
  498.      XEDIT: N/A
  499.      KEDIT: Compatible.
  500.  
  501. SEE ALSO
  502.      SOS DELBACK
  503.  
  504. STATUS
  505.      Complete
  506. **man-end**********************************************************************/
  507. #ifdef PROTO
  508. short Sos_delchar(CHARTYPE *params)
  509. #else
  510. short Sos_delchar(params)
  511. CHARTYPE *params;
  512. #endif
  513. /***********************************************************************/
  514. {
  515. /*------------------------- external data -----------------------------*/
  516.  extern CHARTYPE *rec;
  517.  extern LENGTHTYPE rec_len;
  518.  extern CHARTYPE *cmd_rec;
  519.  extern unsigned short cmd_rec_len;
  520.  extern CHARTYPE *pre_rec;
  521.  extern unsigned short pre_rec_len;
  522.  extern bool prefix_changed;
  523.  extern bool readonly;
  524.  extern VIEW_DETAILS *vd_mark;
  525. /*--------------------------- local data ------------------------------*/
  526.  unsigned short x=0,y=0;
  527. /*--------------------------- processing ------------------------------*/
  528. #ifdef TRACE
  529.  trace_function("commsos.c: Sos_delchar");
  530. #endif
  531. /*---------------------------------------------------------------------*/
  532. /* If running in read-only mode and an attempt is made to execute this */
  533. /* command in the MAIN window, then error...                           */
  534. /*---------------------------------------------------------------------*/
  535.  if (readonly && CURRENT_VIEW->current_window == WINDOW_MAIN)
  536.    {
  537.     display_error(56,"",FALSE);
  538. #ifdef TRACE
  539.     trace_return();
  540. #endif
  541.     return(RC_INVALID_ENVIRON);
  542.    }
  543.  getyx(CURRENT_WINDOW,y,x);
  544.  switch (CURRENT_VIEW->current_window)
  545.    {
  546.     case WINDOW_COMMAND:
  547.          my_wdelch(CURRENT_WINDOW);
  548.          if (x < cmd_rec_len)
  549.            {
  550.             memdelchr(cmd_rec,x,cmd_rec_len,1);
  551.             cmd_rec_len--;
  552.            }
  553. #ifdef TRACE
  554.          trace_return();
  555. #endif
  556.          return(RC_OK);
  557.          break;
  558.     case WINDOW_PREFIX:
  559.          my_wdelch(CURRENT_WINDOW);
  560.          if (x < pre_rec_len)
  561.            {
  562.             prefix_changed = TRUE;
  563.             memdelchr(pre_rec,x,pre_rec_len,1);
  564.             pre_rec_len--;
  565.            }
  566. #ifdef TRACE
  567.          trace_return();
  568. #endif
  569.          return(RC_OK);
  570.          break;
  571.     case WINDOW_MAIN:
  572. /*---------------------------------------------------------------------*/
  573. /* Do not allow this command on the top or bottom of file lines or on  */
  574. /* shadow lines.                                                       */
  575. /*---------------------------------------------------------------------*/
  576.          if (CURRENT_SCREEN.sl[y].line_type != LINE_LINE)
  577.            {
  578.             display_error(38,(CHARTYPE *)"",FALSE);
  579. #ifdef TRACE
  580.             trace_return();
  581. #endif
  582.             return(RC_INVALID_ENVIRON);
  583.            }
  584.          my_wdelch(CURRENT_WINDOW);
  585.          break;
  586.     default:
  587.          break;
  588.    }
  589. /*---------------------------------------------------------------------*/
  590. /* If we are not after the last character of the line...               */
  591. /*---------------------------------------------------------------------*/
  592.  if (x+CURRENT_VIEW->verify_col <= rec_len)
  593.    {
  594.     memdelchr(rec,CURRENT_VIEW->verify_col-1+x,rec_len,1);
  595.     rec_len--;
  596. /*---------------------------------------------------------------------*/
  597. /* If there is a character off the right edge of the screen, display it*/
  598. /* in the last character of the main window.                           */
  599. /*---------------------------------------------------------------------*/
  600.     if (CURRENT_VIEW->verify_col-1+CURRENT_SCREEN.cols[WINDOW_MAIN]-1 < rec_len)
  601.       {
  602.        wmove(CURRENT_WINDOW,y,CURRENT_SCREEN.cols[WINDOW_MAIN]-1);
  603.        put_char(CURRENT_WINDOW,rec[CURRENT_VIEW->verify_col-1+CURRENT_SCREEN.cols[WINDOW_MAIN]-1],ADDCHAR);
  604.        wmove(CURRENT_WINDOW,y,x);
  605.       }
  606.    }
  607. /*---------------------------------------------------------------------*/
  608. /* If the character being deleted is on a line which is in the marked  */
  609. /* block, redisplay the window.                                        */
  610. /*---------------------------------------------------------------------*/
  611.  if (CURRENT_VIEW == MARK_VIEW)
  612.    {
  613.     if (CURRENT_VIEW->focus_line >= MARK_VIEW->mark_start_line
  614.     &&  CURRENT_VIEW->focus_line <= MARK_VIEW->mark_end_line)
  615.       {
  616.        build_current_screen();
  617.        display_current_screen();
  618.       }
  619.    }
  620. #ifdef TRACE
  621.  trace_return();
  622. #endif
  623.  return(RC_OK);
  624. }
  625. /*man-start*********************************************************************
  626. COMMAND
  627.      sos delend - delete to end of line
  628.  
  629. SYNTAX
  630.      SOS DELEnd
  631.  
  632. DESCRIPTION
  633.      The SOS DELEND command deletes all characters from the current
  634.      column to the end of line.
  635.  
  636. COMPATIBILITY
  637.      XEDIT: N/A
  638.      KEDIT: Compatible.
  639.  
  640. STATUS
  641.      Complete.
  642. **man-end**********************************************************************/
  643. #ifdef PROTO
  644. short Sos_delend(CHARTYPE *params)
  645. #else
  646. short Sos_delend(params)
  647. CHARTYPE *params;
  648. #endif
  649. /***********************************************************************/
  650. {
  651. /*-------------------------- external data ----------------------------*/
  652.  extern CHARTYPE *rec;
  653.  extern LENGTHTYPE rec_len;
  654.  extern CHARTYPE *cmd_rec;
  655.  extern unsigned short cmd_rec_len;
  656.  extern CHARTYPE *pre_rec;
  657.  extern unsigned short pre_rec_len;
  658.  extern bool prefix_changed;
  659.  extern bool readonly;
  660.  extern VIEW_DETAILS *vd_mark;
  661. /*--------------------------- local data ------------------------------*/
  662.  register short i=0;
  663.  unsigned short col=0,x=0,y=0;
  664. /*--------------------------- processing ------------------------------*/
  665. #ifdef TRACE
  666.  trace_function("commsos.c: Sos_delend");
  667. #endif
  668.  getyx(CURRENT_WINDOW,y,x);
  669.  switch (CURRENT_VIEW->current_window)
  670.    {
  671.     case WINDOW_MAIN:
  672. /*---------------------------------------------------------------------*/
  673. /* If running in read-only mode and an attempt is made to execute this */
  674. /* command in the MAIN window, then error...                           */
  675. /*---------------------------------------------------------------------*/
  676.          if (readonly)
  677.            {
  678.             display_error(56,"",FALSE);
  679. #ifdef TRACE
  680.             trace_return();
  681. #endif
  682.             return(RC_INVALID_ENVIRON);
  683.            }
  684.          if (CURRENT_SCREEN.sl[y].line_type != LINE_LINE)
  685.            {
  686.             display_error(38,(CHARTYPE *)"",FALSE);
  687. #ifdef TRACE
  688.             trace_return();
  689. #endif
  690.             return(RC_INVALID_ENVIRON);
  691.            }
  692.          col = x + CURRENT_VIEW->verify_col - 1;
  693.          for (i=col;i<max_line_length;i++)
  694.              rec[i] = ' ';
  695.          if (rec_len > col)
  696.             rec_len = col;
  697.          my_wclrtoeol(CURRENT_WINDOW);
  698.          break;
  699.     case WINDOW_COMMAND:
  700.          for (i=x;i<COLS;i++)
  701.              cmd_rec[i] = ' ';
  702.          if (cmd_rec_len > x)
  703.             cmd_rec_len = x;
  704.          my_wclrtoeol(CURRENT_WINDOW);
  705.          break;
  706.     case WINDOW_PREFIX:
  707.          prefix_changed = TRUE;
  708.          for (i=x;i<PREFIX_WIDTH;i++)
  709.              pre_rec[i] = ' ';
  710.          if (pre_rec_len > x)
  711.             pre_rec_len = x;
  712.          my_wclrtoeol(CURRENT_WINDOW);
  713.          break;
  714.     default:
  715.          break;
  716.    }
  717. /*---------------------------------------------------------------------*/
  718. /* If the character being deleted is on a line which is in the marked  */
  719. /* block, and we are in the filearea, redisplay the screen.            */
  720. /*---------------------------------------------------------------------*/
  721.  if (CURRENT_VIEW == MARK_VIEW
  722.  &&  CURRENT_VIEW->current_window == WINDOW_MAIN)
  723.    {
  724.     if (CURRENT_VIEW->focus_line >= MARK_VIEW->mark_start_line
  725.     &&  CURRENT_VIEW->focus_line <= MARK_VIEW->mark_end_line)
  726.       {
  727.        build_current_screen();
  728.        display_current_screen();
  729.       }
  730.    }
  731. #ifdef TRACE
  732.  trace_return();
  733. #endif
  734.  return(RC_OK);
  735. }
  736. /*man-start*********************************************************************
  737. COMMAND
  738.      sos delline - delete focus line
  739.  
  740. SYNTAX
  741.      SOS DELLine
  742.  
  743. DESCRIPTION
  744.      The SOS DELLINE command deletes the focus line.
  745.  
  746. COMPATIBILITY
  747.      XEDIT: Compatible.
  748.      KEDIT: Compatible.
  749.  
  750. SEE ALSO
  751.      SOS LINEDEL, SOS ADDLINE
  752.  
  753. STATUS
  754.      Complete
  755. **man-end**********************************************************************/
  756. #ifdef PROTO
  757. short Sos_delline(CHARTYPE *params)
  758. #else
  759. short Sos_delline(params)
  760. CHARTYPE *params;
  761. #endif
  762. /***********************************************************************/
  763. {
  764. /*-------------------------- external data ----------------------------*/
  765. /*--------------------------- local data ------------------------------*/
  766.  short rc=RC_OK;
  767.  unsigned short x=0,y=0;
  768.  LINETYPE true_line=0L;
  769. /*--------------------------- processing ------------------------------*/
  770. #ifdef TRACE
  771.  trace_function("commsos.c: Sos_delline");
  772. #endif
  773.  if (CURRENT_VIEW->current_window == WINDOW_MAIN
  774.  ||  CURRENT_VIEW->current_window == WINDOW_PREFIX)
  775.    {
  776.     getyx(CURRENT_WINDOW,y,x);
  777.     if (CURRENT_SCREEN.sl[y].line_type != LINE_LINE
  778.     &&  !CURRENT_VIEW->scope_all)
  779.       {
  780.        display_error(38,(CHARTYPE *)"",FALSE);
  781. #ifdef TRACE
  782.        trace_return();
  783. #endif
  784.        return(RC_INVALID_ENVIRON);
  785.       }
  786.    }
  787.  true_line = CURRENT_VIEW->focus_line;
  788.  rc = rearrange_line_blocks(COMMAND_DELETE,SOURCE_COMMAND,true_line,
  789.                             true_line,true_line,1,CURRENT_VIEW,CURRENT_VIEW,FALSE);
  790. /* rc = DeleteLine("1");*/
  791. #ifdef TRACE
  792.  trace_return();
  793. #endif
  794.  return(rc);
  795. }
  796. /*man-start*********************************************************************
  797. COMMAND
  798.      sos delword - delete word at or right of cursor
  799.  
  800. SYNTAX
  801.      SOS DELWord
  802.  
  803. DESCRIPTION
  804.      The SOS DELWORD command deletes the word at or to the right
  805.      of the current cursor position and any spaces following the 
  806.      word.
  807.  
  808. COMPATIBILITY
  809.      XEDIT: N/A
  810.      KEDIT: Compatible.
  811.  
  812. STATUS
  813.      Complete
  814. **man-end**********************************************************************/
  815. #ifdef PROTO
  816. short Sos_delword(CHARTYPE *params)
  817. #else
  818. short Sos_delword(params)
  819. CHARTYPE *params;
  820. #endif
  821. /***********************************************************************/
  822. {
  823. /*-------------------------- external data ----------------------------*/
  824.  extern CHARTYPE *rec;
  825.  extern LENGTHTYPE rec_len;
  826.  extern CHARTYPE *cmd_rec;
  827.  extern unsigned short cmd_rec_len;
  828.  extern bool readonly;
  829. /*--------------------------- local data ------------------------------*/
  830.  register short i=0;
  831.  short rc=RC_OK;
  832.  LENGTHTYPE first_col=0,last_col=0;
  833.  unsigned short x=0,y=0,temp_rec_len=0;
  834.  short num_cols=0,left_col=0,col_pos=0;
  835.  CHARTYPE *temp_rec=NULL;
  836. /*--------------------------- processing ------------------------------*/
  837. #ifdef TRACE
  838.  trace_function("commsos.c: Sos_delword");
  839. #endif
  840. /*---------------------------------------------------------------------*/
  841. /* This function is not applicable to the PREFIX window.               */
  842. /*---------------------------------------------------------------------*/
  843.  getyx(CURRENT_WINDOW,y,x);
  844.  switch(CURRENT_VIEW->current_window)
  845.    {
  846.     case WINDOW_PREFIX:
  847.          display_error(38,(CHARTYPE *)"",FALSE);
  848. #ifdef TRACE
  849.          trace_return();
  850. #endif
  851.          return(RC_INVALID_ENVIRON);
  852.          break;
  853.     case WINDOW_MAIN:
  854. /*---------------------------------------------------------------------*/
  855. /* If running in read-only mode and an attempt is made to execute this */
  856. /* command in the MAIN window, then error...                           */
  857. /*---------------------------------------------------------------------*/
  858.          if (readonly)
  859.            {
  860.             display_error(56,"",FALSE);
  861. #ifdef TRACE
  862.             trace_return();
  863. #endif
  864.             return(RC_INVALID_ENVIRON);
  865.            }
  866.          if (CURRENT_SCREEN.sl[y].line_type != LINE_LINE)
  867.            {
  868.             display_error(38,(CHARTYPE *)"",FALSE);
  869. #ifdef TRACE
  870.             trace_return();
  871. #endif
  872.             return(RC_INVALID_ENVIRON);
  873.            }
  874.          temp_rec = rec;
  875.          temp_rec_len = rec_len;
  876.          left_col = CURRENT_VIEW->verify_col-1;
  877.          break;
  878.     case WINDOW_COMMAND:
  879.          temp_rec = (CHARTYPE *)cmd_rec;
  880.          temp_rec_len = cmd_rec_len;
  881.          left_col = 0;
  882.          break;
  883.    }
  884.  if (get_word(temp_rec,temp_rec_len,x+left_col,&first_col,&last_col) == 0)
  885.    {
  886. #ifdef TRACE
  887.     trace_return();
  888. #endif
  889.     return(0);
  890.    }
  891. /*---------------------------------------------------------------------*/
  892. /* Delete from the field the number of columns calculated above        */
  893. /* and adjust the appropriate record length.                           */
  894. /*---------------------------------------------------------------------*/
  895.  num_cols = last_col-first_col+1;
  896.  memdelchr(temp_rec,first_col,temp_rec_len,num_cols);
  897.  switch(CURRENT_VIEW->current_window)
  898.    {
  899.     case WINDOW_MAIN:
  900.          rec_len -= num_cols;
  901.          col_pos = x;
  902.          if (first_col >= left_col)
  903.            {
  904.             build_current_screen(); 
  905.             display_current_screen();
  906.             wmove(CURRENT_WINDOW,y,first_col);
  907.            }
  908.          else
  909.            {
  910.             x = CURRENT_SCREEN.cols[WINDOW_MAIN] / 2;
  911.             CURRENT_VIEW->verify_col = max(1,first_col - x + 2);
  912.             x = (CURRENT_VIEW->verify_col == 1) ? first_col : x - 1;
  913.             wmove(CURRENT_WINDOW,y,x);
  914.             build_current_screen(); 
  915.             display_current_screen();
  916.            }
  917.          break;
  918.     case WINDOW_COMMAND:
  919.          cmd_rec_len -= num_cols;
  920.          wmove(CURRENT_WINDOW,y,first_col);
  921.          for (i=0;i<num_cols;i++)
  922.             my_wdelch(CURRENT_WINDOW);
  923.          break;
  924.    }
  925. #ifdef TRACE
  926.  trace_return();
  927. #endif
  928.  return(rc);
  929. }
  930. /*man-start*********************************************************************
  931. COMMAND
  932.      sos doprefix - execute any pending prefix commands
  933.  
  934. SYNTAX
  935.      SOS DOPREfix
  936.  
  937. DESCRIPTION
  938.      The SOS DOPREFIX command executes any pending prefix commands.
  939.  
  940. COMPATIBILITY
  941.      XEDIT: N/A
  942.      KEDIT: Compatible.
  943.  
  944. STATUS
  945.      Complete
  946. **man-end**********************************************************************/
  947. #ifdef PROTO
  948. short Sos_doprefix(CHARTYPE *params)
  949. #else
  950. short Sos_doprefix(params)
  951. CHARTYPE *params;
  952. #endif
  953. /***********************************************************************/
  954. {
  955. /*------------------------- external data -----------------------------*/
  956. /*--------------------------- local data ------------------------------*/
  957.  short rc=RC_OK;
  958. /*--------------------------- processing ------------------------------*/
  959. #ifdef TRACE
  960.  trace_function("commsos.c: Sos_doprefix");
  961. #endif
  962. /*---------------------------------------------------------------------*/
  963. /*                                                                     */
  964. /*---------------------------------------------------------------------*/
  965. /* post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);*/
  966.  rc = execute_prefix_commands();
  967. #ifdef TRACE
  968.  trace_return();
  969. #endif
  970.  return(rc);
  971. }
  972. /*man-start*********************************************************************
  973. COMMAND
  974.      sos edit - edit a file from directory list
  975.  
  976. SYNTAX
  977.      SOS EDIT
  978.  
  979. DESCRIPTION
  980.      The SOS EDIT command allows the user to edit a file, chosen from
  981.      a directory list.(the file DIR.DIR).
  982.  
  983. COMPATIBILITY
  984.      XEDIT: N/A
  985.      KEDIT: Compatible with default definition for Alt-X key.
  986.  
  987. STATUS
  988.      Complete.
  989. **man-end**********************************************************************/
  990. #ifdef PROTO
  991. short Sos_edit(CHARTYPE *params)
  992. #else
  993. short Sos_edit(params)
  994. CHARTYPE *params;
  995. #endif
  996. /***********************************************************************/
  997. {
  998. /*-------------------------- external data ----------------------------*/
  999.  extern CHARTYPE sp_path[MAX_FILE_NAME+1];
  1000.  extern CHARTYPE sp_fname[MAX_FILE_NAME+1];
  1001.  extern CHARTYPE dir_path[MAX_FILE_NAME+1];
  1002.  extern unsigned short file_start;
  1003.  extern CHARTYPE *temp_cmd;
  1004. /*--------------------------- local data ------------------------------*/
  1005.  LINE *curr=NULL;
  1006.  CHARTYPE edit_fname[MAX_FILE_NAME];
  1007.  unsigned short y=0,x=0;
  1008.  short rc=RC_OK;
  1009.  LINETYPE true_line=0L;
  1010. /*--------------------------- processing ------------------------------*/
  1011. #ifdef TRACE
  1012.  trace_function("commsos.c: Sos_edit");
  1013. #endif
  1014. /*---------------------------------------------------------------------*/
  1015. /* If the current file is not the special DIR.DIR file exit.           */
  1016. /*---------------------------------------------------------------------*/
  1017.  if (CURRENT_FILE->pseudo_file != PSEUDO_DIR)
  1018.    {
  1019. #ifdef TRACE
  1020.     trace_return();
  1021. #endif
  1022.     return(RC_INVALID_ENVIRON);
  1023.    }
  1024. /*---------------------------------------------------------------------*/
  1025. /* Determine which line contains a vaild file to edit. TOF and EOF are */
  1026. /* invalid positions.                                                  */
  1027. /*---------------------------------------------------------------------*/
  1028.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
  1029.    {
  1030.     if (CURRENT_TOF || CURRENT_BOF)
  1031.       {
  1032. #ifdef TRACE
  1033.        trace_return();
  1034. #endif
  1035.        return(RC_INVALID_ENVIRON);
  1036.       }
  1037.     true_line = CURRENT_VIEW->current_line;
  1038.    }
  1039.  else
  1040.    {
  1041.     getyx(CURRENT_WINDOW,y,x);
  1042.     if (FOCUS_TOF || FOCUS_BOF)
  1043.       {
  1044. #ifdef TRACE
  1045.        trace_return();
  1046. #endif
  1047.        return(RC_INVALID_ENVIRON);
  1048.       }
  1049.     true_line = CURRENT_VIEW->focus_line;
  1050.    }
  1051. /*---------------------------------------------------------------------*/
  1052. /* Find the current LINE pointer for the focus_line.                   */
  1053. /*---------------------------------------------------------------------*/
  1054.  curr = lll_find(CURRENT_FILE->first_line,true_line);
  1055. /*---------------------------------------------------------------------*/
  1056.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  1057. /*---------------------------------------------------------------------*/
  1058. /* Validate that the supplied file is valid.                           */
  1059. /*---------------------------------------------------------------------*/
  1060.  strcpy(edit_fname,dir_path);
  1061.  strcat(edit_fname,(CHARTYPE *)curr->line+file_start);
  1062.  if ((rc = splitpath(edit_fname)) != RC_OK)
  1063.    {
  1064.     display_error(10,temp_cmd,FALSE);
  1065. #ifdef TRACE
  1066.     trace_return();
  1067. #endif
  1068.     return(rc);
  1069.    }
  1070. /*---------------------------------------------------------------------*/
  1071. /* Edit the file.                                                      */
  1072. /*---------------------------------------------------------------------*/
  1073.  strcpy(edit_fname,sp_path);
  1074.  strcat(edit_fname,sp_fname);
  1075.  rc = Xedit(edit_fname);
  1076. #ifdef TRACE
  1077.  trace_return();
  1078. #endif
  1079.  return(rc);
  1080. }
  1081. /*man-start*********************************************************************
  1082. COMMAND
  1083.      sos endchar - move cursor to end of focus line
  1084.  
  1085. SYNTAX
  1086.      SOS ENDChar
  1087.  
  1088. DESCRIPTION
  1089.      The SOS ENDCHAR command moves the cursor to the position after
  1090.      the last character displayed in the current window.
  1091.  
  1092. COMPATIBILITY
  1093.      XEDIT: N/A
  1094.      KEDIT: Compatible.
  1095.  
  1096. SEE ALSO
  1097.      SOS STARTENDCHAR
  1098.  
  1099. STATUS
  1100.      Complete.
  1101. **man-end**********************************************************************/
  1102. #ifdef PROTO
  1103. short Sos_endchar(CHARTYPE *params)
  1104. #else
  1105. short Sos_endchar(params)
  1106. CHARTYPE *params;
  1107. #endif
  1108. /***********************************************************************/
  1109. {
  1110. /*-------------------------- external data ----------------------------*/
  1111.  extern LENGTHTYPE rec_len;
  1112.  extern LENGTHTYPE cmd_rec_len;
  1113.  short rc=RC_OK;
  1114. /*--------------------------- local data ------------------------------*/
  1115.  unsigned short x=0,y=0;
  1116. /*--------------------------- processing ------------------------------*/
  1117. #ifdef TRACE
  1118.  trace_function("commsos.c: Sos_endchar");
  1119. #endif
  1120.  getyx(CURRENT_WINDOW,y,x);
  1121.  switch(CURRENT_VIEW->current_window)
  1122.    {
  1123.     case WINDOW_PREFIX:
  1124.          rc = RC_INVALID_ENVIRON;
  1125.          break;
  1126.     case WINDOW_COMMAND:
  1127.          wmove(CURRENT_WINDOW,y,cmd_rec_len);
  1128.          rc = RC_OK;
  1129.          break;
  1130.     case WINDOW_MAIN:
  1131.          rc = execute_move_cursor(rec_len);
  1132.          break;
  1133.    }
  1134. #ifdef TRACE
  1135.  trace_return();
  1136. #endif
  1137.  return(rc);
  1138. }
  1139. /*man-start*********************************************************************
  1140. COMMAND
  1141.      sos execute - move cursor to command line and execute command
  1142.  
  1143. SYNTAX
  1144.      SOS EXecute
  1145.  
  1146. DESCRIPTION
  1147.      The SOS EXECUTE command moves the cursor to the command line
  1148.      and executes any command that is on the command line.
  1149.  
  1150. COMPATIBILITY
  1151.      XEDIT: N/A
  1152.      KEDIT: Compatible
  1153.  
  1154. STATUS
  1155.      Complete. 
  1156. **man-end**********************************************************************/
  1157. #ifdef PROTO
  1158. short Sos_execute(CHARTYPE *params)
  1159. #else
  1160. short Sos_execute(params)
  1161. CHARTYPE *params;
  1162. #endif
  1163. /***********************************************************************/
  1164. {
  1165. /*-------------------------- external data ----------------------------*/
  1166.  extern CHARTYPE *cmd_rec;
  1167.  extern unsigned short cmd_rec_len;
  1168.  extern CHARTYPE *temp_cmd;
  1169. /*--------------------------- local data ------------------------------*/
  1170.  register short i=0;
  1171.  short rc=RC_OK;
  1172. /*--------------------------- processing ------------------------------*/
  1173. #ifdef TRACE
  1174.  trace_function("commsos.c: Sos_execute");
  1175. #endif
  1176.  
  1177.  if (CURRENT_VIEW->current_window != WINDOW_COMMAND)
  1178.     rc = cursor_cmdline(1);
  1179.  if (rc == RC_OK)
  1180.    {
  1181.     for (i=0;i<cmd_rec_len;i++)
  1182.        temp_cmd[i] = cmd_rec[i];
  1183.     temp_cmd[cmd_rec_len] = '\0';
  1184.     strtrunc(temp_cmd);
  1185.     add_command(temp_cmd);
  1186.     rc = command_line(temp_cmd,COMMAND_ONLY_FALSE);
  1187.    }
  1188. #ifdef TRACE
  1189.  trace_return();
  1190. #endif
  1191.  return(rc);
  1192. }
  1193. /*man-start*********************************************************************
  1194. COMMAND
  1195.      sos firstchar - move cursor to first non-blank of field
  1196.  
  1197. SYNTAX
  1198.      SOS FIRSTCHar
  1199.  
  1200. DESCRIPTION
  1201.      The SOS FIRSTCHAR command moves the cursor to the first
  1202.      non-blank character of the cursor field
  1203.  
  1204. COMPATIBILITY
  1205.      XEDIT: N/A
  1206.      KEDIT: Compatible
  1207.  
  1208. SEE ALSO
  1209.      SOS FIRSTCOL
  1210.  
  1211. STATUS
  1212.      Complete.
  1213. **man-end**********************************************************************/
  1214. #ifdef PROTO
  1215. short Sos_firstchar(CHARTYPE *params)
  1216. #else
  1217. short Sos_firstchar(params)
  1218. CHARTYPE *params;
  1219. #endif
  1220. /***********************************************************************/
  1221. {
  1222. /*-------------------------- external data ----------------------------*/
  1223. /*--------------------------- local data ------------------------------*/
  1224.  short rc=RC_OK,new_col=0;
  1225.  unsigned short y=0,x=0;
  1226.  LINE *curr=NULL;
  1227. /*--------------------------- processing ------------------------------*/
  1228. #ifdef TRACE
  1229.  trace_function("commsos.c: Sos_firstchar");
  1230. #endif
  1231. /*---------------------------------------------------------------------*/
  1232. /* For the command line and prefix area, just go to the first column...*/
  1233. /*---------------------------------------------------------------------*/
  1234.  getyx(CURRENT_WINDOW,y,x);
  1235.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND
  1236.  ||  CURRENT_VIEW->current_window == WINDOW_PREFIX)
  1237.    {
  1238.     wmove(CURRENT_WINDOW,y,0);
  1239. #ifdef TRACE
  1240.     trace_return();
  1241. #endif
  1242.     return(rc);
  1243.    }
  1244. /*---------------------------------------------------------------------*/
  1245. /* For the filearea, we have to do a bit more...                       */
  1246. /*---------------------------------------------------------------------*/
  1247.  curr = CURRENT_SCREEN.sl[y].current;
  1248.  new_col = memne(curr->line,' ',curr->length);
  1249.  if (new_col == (-1))
  1250.     new_col = 0;
  1251.  rc = execute_move_cursor(new_col);
  1252. #ifdef TRACE
  1253.  trace_return();
  1254. #endif
  1255.  return(rc);
  1256. }
  1257. /*man-start*********************************************************************
  1258. COMMAND
  1259.      sos firstcol - move cursor to first column of field
  1260.  
  1261. SYNTAX
  1262.      SOS FIRSTCOl
  1263.  
  1264. DESCRIPTION
  1265.      The SOS FIRSTCOL command moves the cursor to the first
  1266.      column of the cursor field
  1267.  
  1268. COMPATIBILITY
  1269.      XEDIT: N/A
  1270.      KEDIT: Compatible
  1271.  
  1272. SEE ALSO
  1273.      SOS FIRSTCHAR, SOS LASTCOL
  1274.  
  1275. STATUS
  1276.      Complete.
  1277. **man-end**********************************************************************/
  1278. #ifdef PROTO
  1279. short Sos_firstcol(CHARTYPE *params)
  1280. #else
  1281. short Sos_firstcol(params)
  1282. CHARTYPE *params;
  1283. #endif
  1284. /***********************************************************************/
  1285. {
  1286. /*-------------------------- external data ----------------------------*/
  1287. /*--------------------------- local data ------------------------------*/
  1288.  short rc=RC_OK;
  1289.  unsigned short y=0,x=0;
  1290. /*--------------------------- processing ------------------------------*/
  1291. #ifdef TRACE
  1292.  trace_function("commsos.c: Sos_firstcol");
  1293. #endif
  1294. /*---------------------------------------------------------------------*/
  1295. /* For the command line and prefix area, just go to the first column...*/
  1296. /*---------------------------------------------------------------------*/
  1297.  getyx(CURRENT_WINDOW,y,x);
  1298.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND
  1299.  ||  CURRENT_VIEW->current_window == WINDOW_PREFIX)
  1300.    {
  1301.     wmove(CURRENT_WINDOW,y,0);
  1302. #ifdef TRACE
  1303.     trace_return();
  1304. #endif
  1305.     return(rc);
  1306.    }
  1307. /*---------------------------------------------------------------------*/
  1308. /* For the filearea, we have to do a bit more...                       */
  1309. /*---------------------------------------------------------------------*/
  1310.  if (CURRENT_VIEW->verify_col != 1)
  1311.    {
  1312.     rc = execute_move_cursor(0);
  1313. #if 0
  1314.     CURRENT_VIEW->verify_col = 1;
  1315.     build_current_screen();
  1316.     display_current_screen();
  1317. #endif
  1318.    }
  1319.  wmove(CURRENT_WINDOW,y,0);
  1320. #ifdef TRACE
  1321.  trace_return();
  1322. #endif
  1323.  return(rc);
  1324. }
  1325. /*man-start*********************************************************************
  1326. COMMAND
  1327.      sos lastcol - move cursor to last column of field
  1328.  
  1329. SYNTAX
  1330.      SOS LASTCOl
  1331.  
  1332. DESCRIPTION
  1333.      The SOS LASTCOL command moves the cursor to the last column
  1334.      of the cursor field.
  1335.  
  1336. COMPATIBILITY
  1337.      XEDIT: N/A
  1338.      KEDIT: N/A
  1339.  
  1340. SEE ALSO
  1341.      SOS FIRSTCOL
  1342.  
  1343. STATUS
  1344.      Complete.
  1345. **man-end**********************************************************************/
  1346. #ifdef PROTO
  1347. short Sos_lastcol(CHARTYPE *params)
  1348. #else
  1349. short Sos_lastcol(params)
  1350. CHARTYPE *params;
  1351. #endif
  1352. /***********************************************************************/
  1353. {
  1354. /*-------------------------- external data ----------------------------*/
  1355.  extern short prefix_width;
  1356. /*--------------------------- local data ------------------------------*/
  1357.  short rc=RC_OK;
  1358.  unsigned short y=0,x=0;
  1359. /*--------------------------- processing ------------------------------*/
  1360. #ifdef TRACE
  1361.  trace_function("commsos.c: Sos_lastcol");
  1362. #endif
  1363. /*---------------------------------------------------------------------*/
  1364. /* For the command line and filearea, just go to the last column...    */
  1365. /*---------------------------------------------------------------------*/
  1366.  getyx(CURRENT_WINDOW,y,x);
  1367.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND
  1368.  ||  CURRENT_VIEW->current_window == WINDOW_MAIN)
  1369.    {
  1370.     x = getmaxx(CURRENT_WINDOW)-1;
  1371.     wmove(CURRENT_WINDOW,y,x);
  1372. #ifdef TRACE
  1373.     trace_return();
  1374. #endif
  1375.     return(rc);
  1376.    }
  1377. /*---------------------------------------------------------------------*/
  1378. /* For the prefix area we have to do a bit more...                     */
  1379. /*---------------------------------------------------------------------*/
  1380.  if ((CURRENT_VIEW->prefix&PREFIX_LOCATION_MASK) == PREFIX_RIGHT
  1381.  &&  prefix_width != PREFIX_WIDTH)
  1382.      x = PREFIX_WIDTH - 1;
  1383.  else
  1384.      x = prefix_width - 1;
  1385.  wmove(CURRENT_WINDOW,y,x);
  1386. #ifdef TRACE
  1387.  trace_return();
  1388. #endif
  1389.  return(rc);
  1390. }
  1391. /*man-start*********************************************************************
  1392. COMMAND
  1393.      sos leftedge - move cursor to left edge of window
  1394.  
  1395. SYNTAX
  1396.      SOS LEFTEdge
  1397.  
  1398. DESCRIPTION
  1399.      The SOS LEFTEDGE command moves the cursor to the leftmost edge
  1400.      of the filearea if not on the command line or to the leftmost
  1401.      edge of the command line if on the command line.
  1402.  
  1403. COMPATIBILITY
  1404.      XEDIT: N/A
  1405.      KEDIT: Compatible
  1406.  
  1407. SEE ALSO
  1408.      SOS RIGHTEDGE, SOS PREFIX
  1409.  
  1410. STATUS
  1411.      Complete.
  1412. **man-end**********************************************************************/
  1413. #ifdef PROTO
  1414. short Sos_leftedge(CHARTYPE *params)
  1415. #else
  1416. short Sos_leftedge(params)
  1417. CHARTYPE *params;
  1418. #endif
  1419. /***********************************************************************/
  1420. {
  1421. /*-------------------------- external data ----------------------------*/
  1422. /*--------------------------- local data ------------------------------*/
  1423.  unsigned short y=0,x=0;
  1424. /*--------------------------- processing ------------------------------*/
  1425. #ifdef TRACE
  1426.  trace_function("commsos.c: Sos_leftedge");
  1427. #endif
  1428.  getyx(CURRENT_WINDOW,y,x);
  1429.  if (CURRENT_VIEW->current_window == WINDOW_PREFIX)
  1430.     CURRENT_VIEW->current_window = WINDOW_MAIN;
  1431.  wmove(CURRENT_WINDOW,y,0);
  1432. #ifdef TRACE
  1433.  trace_return();
  1434. #endif
  1435.  return(RC_OK);
  1436. }
  1437. /*man-start*********************************************************************
  1438. COMMAND
  1439.      sos lineadd - add blank line after focus line
  1440.  
  1441. SYNTAX
  1442.      SOS LINEAdd
  1443.  
  1444. DESCRIPTION
  1445.      The SOS LINEADD command inserts a blank line in the file following
  1446.      the focus line. The cursor is placed in the column under the first
  1447.      non-blank in the focus line.
  1448.  
  1449. COMPATIBILITY
  1450.      XEDIT: Compatible.
  1451.      KEDIT: Compatible.
  1452.  
  1453. SEE ALSO
  1454.      SOS ADDLINE, SOS LINEDEL
  1455.  
  1456. STATUS
  1457.      Complete
  1458. **man-end**********************************************************************/
  1459.  
  1460. /*man-start*********************************************************************
  1461. COMMAND
  1462.      sos linedel - delete focus line
  1463.  
  1464. SYNTAX
  1465.      SOS LINEDel
  1466.  
  1467. DESCRIPTION
  1468.      The SOS LINEDEL command deletes the focus line.
  1469.  
  1470. COMPATIBILITY
  1471.      XEDIT: Compatible.
  1472.      KEDIT: Compatible.
  1473.  
  1474. SEE ALSO
  1475.      SOS DELLINE, SOS LINEADD
  1476.  
  1477. STATUS
  1478.      Complete
  1479. **man-end**********************************************************************/
  1480.  
  1481. /*man-start*********************************************************************
  1482. COMMAND
  1483.      sos makecurr - make focus line the current line
  1484.  
  1485. SYNTAX
  1486.      SOS MAKECURR
  1487.  
  1488. DESCRIPTION
  1489.      The SOS MAKECURR command set the current line to the current focus
  1490.      line.
  1491.  
  1492. COMPATIBILITY
  1493.      XEDIT: N/A
  1494.      KEDIT: Compatible.
  1495.  
  1496. STATUS
  1497.      Complete
  1498. **man-end**********************************************************************/
  1499. #ifdef PROTO
  1500. short Sos_makecurr(CHARTYPE *params)
  1501. #else
  1502. short Sos_makecurr(params)
  1503. CHARTYPE *params;
  1504. #endif
  1505. /***********************************************************************/
  1506. {
  1507. /*-------------------------- external data ----------------------------*/
  1508. /*--------------------------- local data ------------------------------*/
  1509.  short rc=RC_OK;
  1510. /*--------------------------- processing ------------------------------*/
  1511. #ifdef TRACE
  1512.  trace_function("commsos.c: Sos_makecurr");
  1513. #endif
  1514.  rc = execute_makecurr(CURRENT_VIEW->focus_line);
  1515. #ifdef TRACE
  1516.  trace_return();
  1517. #endif
  1518.  return(rc);
  1519. }
  1520. /*man-start*********************************************************************
  1521. COMMAND
  1522.      sos marginl - move cursor to the left margin column
  1523.  
  1524. SYNTAX
  1525.      SOS MARGINL
  1526.  
  1527. DESCRIPTION
  1528.      The SOS MARGINL command moves the cursor to the left margin
  1529.      column.
  1530.  
  1531. COMPATIBILITY
  1532.      XEDIT: N/A
  1533.      KEDIT: Compatible.
  1534.             Although, when issued from the command line, nothing
  1535.             happens.
  1536.  
  1537. STATUS
  1538.      Complete
  1539. **man-end**********************************************************************/
  1540. #ifdef PROTO
  1541. short Sos_marginl(CHARTYPE *params)
  1542. #else
  1543. short Sos_marginl(params)
  1544. CHARTYPE *params;
  1545. #endif
  1546. /***********************************************************************/
  1547. {
  1548. /*-------------------------- external data ----------------------------*/
  1549. /*--------------------------- local data ------------------------------*/
  1550.  short rc=RC_OK;
  1551. /*--------------------------- processing ------------------------------*/
  1552. #ifdef TRACE
  1553.  trace_function("commsos.c: Sos_marginl");
  1554. #endif
  1555.  if (Sos_leftedge("") == RC_OK)
  1556.     rc = execute_move_cursor(CURRENT_VIEW->margin_left-1);
  1557. #ifdef TRACE
  1558.  trace_return();
  1559. #endif
  1560.  return(rc);
  1561. }
  1562. /*man-start*********************************************************************
  1563. COMMAND
  1564.      sos marginr - move cursor to the right margin column
  1565.  
  1566. SYNTAX
  1567.      SOS MARGINR
  1568.  
  1569. DESCRIPTION
  1570.      The SOS MARGINR command moves the cursor to the right margin
  1571.      column.
  1572.  
  1573. COMPATIBILITY
  1574.      XEDIT: N/A
  1575.      KEDIT: Compatible.
  1576.             Although, when issued from the command line, nothing
  1577.             happens.
  1578.  
  1579. STATUS
  1580.      Complete
  1581. **man-end**********************************************************************/
  1582. #ifdef PROTO
  1583. short Sos_marginr(CHARTYPE *params)
  1584. #else
  1585. short Sos_marginr(params)
  1586. CHARTYPE *params;
  1587. #endif
  1588. /***********************************************************************/
  1589. {
  1590. /*-------------------------- external data ----------------------------*/
  1591. /*--------------------------- local data ------------------------------*/
  1592.  short rc=RC_OK;
  1593. /*--------------------------- processing ------------------------------*/
  1594. #ifdef TRACE
  1595.  trace_function("commsos.c: Sos_marginr");
  1596. #endif
  1597.  if (Sos_leftedge("") == RC_OK)
  1598.     rc = execute_move_cursor(CURRENT_VIEW->margin_right-1);
  1599. #ifdef TRACE
  1600.  trace_return();
  1601. #endif
  1602.  return(rc);
  1603. }
  1604. /*man-start*********************************************************************
  1605. COMMAND
  1606.      sos parindent - move cursor to the paragraph indent column
  1607.  
  1608. SYNTAX
  1609.      SOS PARINDent
  1610.  
  1611. DESCRIPTION
  1612.      The SOS PARINDENT command moves the cursor to the paragraph
  1613.      indent column.
  1614.  
  1615. COMPATIBILITY
  1616.      XEDIT: N/A
  1617.      KEDIT: Compatible.
  1618.             Although, when issued from the command line, nothing
  1619.             happens.
  1620.  
  1621. STATUS
  1622.      Complete
  1623. **man-end**********************************************************************/
  1624. #ifdef PROTO
  1625. short Sos_parindent(CHARTYPE *params)
  1626. #else
  1627. short Sos_parindent(params)
  1628. CHARTYPE *params;
  1629. #endif
  1630. /***********************************************************************/
  1631. {
  1632. /*-------------------------- external data ----------------------------*/
  1633. /*--------------------------- local data ------------------------------*/
  1634.  short rc=RC_OK;
  1635.  COLTYPE parindent=0;
  1636. /*--------------------------- processing ------------------------------*/
  1637. #ifdef TRACE
  1638.  trace_function("commsos.c: Sos_parindent");
  1639. #endif
  1640.  if (CURRENT_VIEW->margin_indent_offset)
  1641.     parindent = CURRENT_VIEW->margin_left + CURRENT_VIEW->margin_indent - 1;
  1642.  else
  1643.     parindent = CURRENT_VIEW->margin_indent - 1;
  1644.  if (Sos_leftedge("") == RC_OK)
  1645.     rc = execute_move_cursor(parindent);
  1646. #ifdef TRACE
  1647.  trace_return();
  1648. #endif
  1649.  return(rc);
  1650. }
  1651. /*man-start*********************************************************************
  1652. COMMAND
  1653.      sos prefix - move cursor to leftmost edge of prefix area
  1654.  
  1655. SYNTAX
  1656.      SOS PREfix
  1657.  
  1658. DESCRIPTION
  1659.      The SOS PREFIX command moves the cursor to the rightmost edge
  1660.      of the prefix area.
  1661.  
  1662. COMPATIBILITY
  1663.      XEDIT: N/A
  1664.      KEDIT: Compatible
  1665.  
  1666. SEE ALSO
  1667.      SOS LEFTEDGE, SOS RIGHTEDGE
  1668.  
  1669. STATUS
  1670.      Complete.
  1671. **man-end**********************************************************************/
  1672. #ifdef PROTO
  1673. short Sos_prefix(CHARTYPE *params)
  1674. #else
  1675. short Sos_prefix(params)
  1676. CHARTYPE *params;
  1677. #endif
  1678. /***********************************************************************/
  1679. {
  1680. /*-------------------------- external data ----------------------------*/
  1681.  extern short prefix_width;
  1682. /*--------------------------- local data ------------------------------*/
  1683.  short rc=RC_OK;
  1684.  unsigned short y=0,x=0;
  1685. /*--------------------------- processing ------------------------------*/
  1686. #ifdef TRACE
  1687.  trace_function("commsos.c: Sos_prefix");
  1688. #endif
  1689. /*---------------------------------------------------------------------*/
  1690. /* If the cursor is in the command line or there is no prefix on, exit.*/
  1691. /*---------------------------------------------------------------------*/
  1692.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND
  1693.  ||  !CURRENT_VIEW->prefix)
  1694.    {
  1695. #ifdef TRACE
  1696.     trace_return();
  1697. #endif
  1698.     return(RC_OK);
  1699.    }
  1700.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  1701.  getyx(CURRENT_WINDOW,y,x);
  1702.  if (CURRENT_VIEW->current_window == WINDOW_MAIN)
  1703.     CURRENT_VIEW->current_window = WINDOW_PREFIX;
  1704.  if ((CURRENT_VIEW->prefix&PREFIX_LOCATION_MASK) == PREFIX_RIGHT
  1705.  &&  prefix_width != PREFIX_WIDTH)
  1706.     x = 1;
  1707.  else
  1708.     x = 0;
  1709.  wmove(CURRENT_WINDOW,y,x);
  1710. #ifdef TRACE
  1711.  trace_return();
  1712. #endif
  1713.  return(rc);
  1714. }
  1715. /*man-start*********************************************************************
  1716. COMMAND
  1717.      sos qcmnd - move cursor to command line and clear
  1718.  
  1719. SYNTAX
  1720.      SOS QCmnd
  1721.  
  1722. DESCRIPTION
  1723.      The SOS QCMND command moves the cursor to the first column of
  1724.      the command line and clears the command line.
  1725.  
  1726. COMPATIBILITY
  1727.      XEDIT: N/A
  1728.      KEDIT: Compatible
  1729.  
  1730. SEE ALSO
  1731.      SOS EXECUTE
  1732.  
  1733. STATUS
  1734.      Complete.
  1735. **man-end**********************************************************************/
  1736. #ifdef PROTO
  1737. short Sos_qcmnd(CHARTYPE *params)
  1738. #else
  1739. short Sos_qcmnd(params)
  1740. CHARTYPE *params;
  1741. #endif
  1742. /***********************************************************************/
  1743. {
  1744. /*-------------------------- external data ----------------------------*/
  1745.  extern CHARTYPE *cmd_rec;
  1746.  extern unsigned short cmd_rec_len;
  1747. /*--------------------------- local data ------------------------------*/
  1748.  short rc=RC_OK;
  1749. /*--------------------------- processing ------------------------------*/
  1750. #ifdef TRACE
  1751.  trace_function("commsos.c: Sos_qcmnd");
  1752. #endif
  1753.  if ((rc = cursor_cmdline(1)) == RC_OK)
  1754.    {
  1755.     if (CURRENT_WINDOW_COMMAND != (WINDOW *)NULL)
  1756.       {
  1757.        wmove(CURRENT_WINDOW_COMMAND,0,0);
  1758.        my_wclrtoeol(CURRENT_WINDOW_COMMAND);
  1759.       }
  1760.     memset(cmd_rec,' ',COLS);
  1761.     cmd_rec_len = 0;
  1762.   }
  1763. #ifdef TRACE
  1764.  trace_return();
  1765. #endif
  1766.  return(rc);
  1767. }
  1768. /*man-start*********************************************************************
  1769. COMMAND
  1770.      sos rightedge - move cursor to right edge of window
  1771.  
  1772. SYNTAX
  1773.      SOS RIGHTEdge
  1774.  
  1775. DESCRIPTION
  1776.      The SOS RIGHTEDGE command moves the cursor to the rightmost edge
  1777.      of the filearea if not on the command line or to the rightmost
  1778.      edge of the command line if on the command line.
  1779.  
  1780. COMPATIBILITY
  1781.      XEDIT: N/A
  1782.      KEDIT: Compatible
  1783.  
  1784. SEE ALSO
  1785.      SOS LEFTEDGE, SOS PREFIX
  1786.  
  1787. STATUS
  1788.      Complete.
  1789. **man-end**********************************************************************/
  1790. #ifdef PROTO
  1791. short Sos_rightedge(CHARTYPE *params)
  1792. #else
  1793. short Sos_rightedge(params)
  1794. CHARTYPE *params;
  1795. #endif
  1796. /***********************************************************************/
  1797. {
  1798. /*-------------------------- external data ----------------------------*/
  1799. /*--------------------------- local data ------------------------------*/
  1800.  short rc=RC_OK;
  1801.  unsigned short y=0,x=0;
  1802. /*--------------------------- processing ------------------------------*/
  1803. #ifdef TRACE
  1804.  trace_function("commsos.c: Sos_rightedge");
  1805. #endif
  1806.  getyx(CURRENT_WINDOW,y,x);
  1807.  if (CURRENT_VIEW->current_window == WINDOW_PREFIX)
  1808.     CURRENT_VIEW->current_window = WINDOW_MAIN;
  1809.  x = getmaxx(CURRENT_WINDOW)-1;
  1810.  wmove(CURRENT_WINDOW,y,x);
  1811. #ifdef TRACE
  1812.  trace_return();
  1813. #endif
  1814.  return(rc);
  1815. }
  1816. /*man-start*********************************************************************
  1817. COMMAND
  1818.      sos startendchar - move cursor to end/start of focus line
  1819.  
  1820. SYNTAX
  1821.      SOS STARTENDChar
  1822.  
  1823. DESCRIPTION
  1824.      The SOS STARTENDCHAR command moves the cursor to the first character
  1825.      displayed in the current window, if the cursor is after the last
  1826.      character displayed in the current window, or to the position after
  1827.      the last character displayed in the current window, if the cursor is
  1828.      anywhere else.
  1829.  
  1830. COMPATIBILITY
  1831.      XEDIT: N/A
  1832.      KEDIT: N/A
  1833.  
  1834. SEE ALSO
  1835.      SOS ENDCHAR
  1836.  
  1837. STATUS
  1838.      Complete.
  1839. **man-end**********************************************************************/
  1840. #ifdef PROTO
  1841. short Sos_startendchar(CHARTYPE *params)
  1842. #else
  1843. short Sos_startendchar(params)
  1844. CHARTYPE *params;
  1845. #endif
  1846. /***********************************************************************/
  1847. {
  1848. /*-------------------------- external data ----------------------------*/
  1849.  extern LENGTHTYPE rec_len;
  1850.  extern unsigned short cmd_rec_len;
  1851. /*--------------------------- local data ------------------------------*/
  1852.  unsigned short x=0,y=0,line_col=0;
  1853.  short rc=RC_OK;
  1854. /*--------------------------- processing ------------------------------*/
  1855. #ifdef TRACE
  1856.  trace_function("commsos.c: Sos_startendchar");
  1857. #endif
  1858.  getyx(CURRENT_WINDOW,y,x);
  1859.  switch(CURRENT_VIEW->current_window)
  1860.    {
  1861.     case WINDOW_PREFIX:
  1862.          rc = RC_INVALID_ENVIRON;
  1863.          break;
  1864.     case WINDOW_COMMAND:
  1865.          if (x >= cmd_rec_len)
  1866.             wmove(CURRENT_WINDOW,y,0);
  1867.          else
  1868.             wmove(CURRENT_WINDOW,y,cmd_rec_len);
  1869.          break;
  1870.     case WINDOW_MAIN:
  1871.          if (x + CURRENT_VIEW->verify_col > min(rec_len,CURRENT_VIEW->verify_end))
  1872.             rc = Sos_firstcol("");
  1873.          else
  1874.             rc = Sos_endchar("");
  1875.          break;
  1876.    }
  1877. #ifdef TRACE
  1878.  trace_return();
  1879. #endif
  1880.  return(rc);
  1881. }
  1882. /*man-start*********************************************************************
  1883. COMMAND
  1884.      sos tabb - move cursor to previous tab stop
  1885.  
  1886. SYNTAX
  1887.      SOS TABB
  1888.  
  1889. DESCRIPTION
  1890.      The SOS TABB command causes the cursor to move to the previous tab
  1891.      column as set by the SET TABS command.
  1892.      If the resulting column is beyond the left hand edge of the main
  1893.      window, the window will scroll half a window.
  1894.  
  1895. COMPATIBILITY
  1896.      XEDIT: Does not allow arguments.
  1897.      KEDIT: Compatible. See below.
  1898.      Does not line tab to next line if before the left hand tab column.
  1899.  
  1900. SEE ALSO
  1901.      SET TABS, SOS TABF
  1902.  
  1903. STATUS
  1904.      Complete.
  1905. **man-end**********************************************************************/
  1906. #ifdef PROTO
  1907. short Sos_tabb(CHARTYPE *params)
  1908. #else
  1909. short Sos_tabb(params)
  1910. CHARTYPE *params;
  1911. #endif
  1912. /***********************************************************************/
  1913. {
  1914. /*-------------------------- external data ----------------------------*/
  1915. /*--------------------------- local data ------------------------------*/
  1916.  unsigned short x=0,y=0;
  1917.  LENGTHTYPE prev_tab_col=0,current_col=0;
  1918.  COLTYPE new_screen_col=0;
  1919.  LENGTHTYPE new_verify_col=0;
  1920.  short rc=RC_OK;
  1921. /*--------------------------- processing ------------------------------*/
  1922. #ifdef TRACE
  1923.  trace_function("commsos.c: Sos_tabb");
  1924. #endif
  1925.  getyx(CURRENT_WINDOW,y,x);
  1926. /*---------------------------------------------------------------------*/
  1927. /* Determine action depending on current window...                     */
  1928. /*---------------------------------------------------------------------*/
  1929.  switch(CURRENT_VIEW->current_window)
  1930.    {
  1931.     case WINDOW_PREFIX:
  1932. #ifdef TRACE
  1933.          trace_return();
  1934. #endif
  1935.          return(RC_OK);
  1936.          break;
  1937.     case WINDOW_MAIN:
  1938.          current_col = x+CURRENT_VIEW->verify_col;
  1939.          break;
  1940.     case WINDOW_COMMAND:
  1941.          current_col = x+1;
  1942.          break;
  1943.    }
  1944. /*---------------------------------------------------------------------*/
  1945. /* First determine the next tab stop column...                         */
  1946. /*---------------------------------------------------------------------*/
  1947.  prev_tab_col = find_prev_tab_col(current_col);
  1948. /*---------------------------------------------------------------------*/
  1949. /* If no prev tab column, stay where we are and return...              */
  1950. /*---------------------------------------------------------------------*/
  1951.  if (prev_tab_col == 0)
  1952.    {
  1953. #ifdef TRACE
  1954.     trace_return();
  1955. #endif
  1956.     return(RC_OK);
  1957.    }
  1958. /*---------------------------------------------------------------------*/
  1959. /* For all windows, if the new cursor position does not exceed the     */
  1960. /* right edge, move there.                                             */
  1961. /*---------------------------------------------------------------------*/
  1962.  prev_tab_col--;                               /* zero base the column */
  1963.  
  1964. #ifdef VERSHIFT
  1965.  rc = execute_move_cursor(prev_tab_col);
  1966. #else
  1967.  calculate_new_column(x,CURRENT_VIEW->verify_col,prev_tab_col,&new_screen_col,&new_verify_col);
  1968.  if (CURRENT_VIEW->verify_col != new_verify_col
  1969.  &&  CURRENT_VIEW->current_window == WINDOW_MAIN)
  1970.    {
  1971.     CURRENT_VIEW->verify_col = new_verify_col;
  1972.     build_current_screen(); 
  1973.     display_current_screen();
  1974.    }
  1975.  wmove(CURRENT_WINDOW,y,new_screen_col);
  1976. #endif
  1977.  
  1978. #ifdef TRACE
  1979.  trace_return();
  1980. #endif
  1981.  return(rc);
  1982. }
  1983. /*man-start*********************************************************************
  1984. COMMAND
  1985.      sos tabf - move cursor to next tab stop
  1986.  
  1987. SYNTAX
  1988.      SOS TABf
  1989.  
  1990. DESCRIPTION
  1991.      The SOS TABF command causes the cursor to move to the next tab column
  1992.      as set by the SET TABS command.
  1993.      If the resulting column is beyond the right hand edge of the main
  1994.      window, the window will scroll half a window.
  1995.  
  1996. COMPATIBILITY
  1997.      XEDIT: Does not allow arguments.
  1998.      KEDIT: Compatible. See below.
  1999.      Does not line tab to next line if after the right hand tab column.
  2000.  
  2001. SEE ALSO
  2002.      SET TABS, SOS TABB
  2003.  
  2004. STATUS
  2005.      Complete.
  2006. **man-end**********************************************************************/
  2007. #ifdef PROTO
  2008. short Sos_tabf(CHARTYPE *params)
  2009. #else
  2010. short Sos_tabf(params)
  2011. CHARTYPE *params;
  2012. #endif
  2013. /***********************************************************************/
  2014. {
  2015. /*-------------------------- external data ----------------------------*/
  2016.  extern bool INSERTMODEx;
  2017.  extern CHARTYPE tabkey_insert,tabkey_overwrite;
  2018. /*--------------------------- local data ------------------------------*/
  2019.  unsigned short x=0,y=0;
  2020.  LENGTHTYPE next_tab_col=0,current_col=0;
  2021.  COLTYPE new_screen_col=0;
  2022.  LENGTHTYPE new_verify_col=0;
  2023.  short rc=RC_OK;
  2024. /*--------------------------- processing ------------------------------*/
  2025. #ifdef TRACE
  2026.  trace_function("commsos.c: Sos_tabf");
  2027. #endif
  2028. /*---------------------------------------------------------------------*/
  2029. /* If the actual tab character is to be display then exit so that      */
  2030. /* editor() can process it as a raw key.                               */
  2031. /*---------------------------------------------------------------------*/
  2032.  if (INSERTMODEx && tabkey_insert == 'C')
  2033.    {
  2034. #ifdef TRACE
  2035.     trace_return();
  2036. #endif
  2037.     return(RAW_KEY);
  2038.    }
  2039.  if (!INSERTMODEx && tabkey_overwrite == 'C')
  2040.    {
  2041. #ifdef TRACE
  2042.     trace_return();
  2043. #endif
  2044.     return(RAW_KEY);
  2045.    }
  2046.  getyx(CURRENT_WINDOW,y,x);
  2047. /*---------------------------------------------------------------------*/
  2048. /* Determine action depending on current window...                     */
  2049. /*---------------------------------------------------------------------*/
  2050.  switch(CURRENT_VIEW->current_window)
  2051.    {
  2052.     case WINDOW_PREFIX:
  2053. #ifdef TRACE
  2054.          trace_return();
  2055. #endif
  2056.          return(RC_OK);
  2057.          break;
  2058.     case WINDOW_MAIN:
  2059.          current_col = x+CURRENT_VIEW->verify_col;
  2060.          break;
  2061.     case WINDOW_COMMAND:
  2062.          current_col = x+1;
  2063.          break;
  2064.    }
  2065. /*---------------------------------------------------------------------*/
  2066. /* First determine the next tab stop column...                         */
  2067. /*---------------------------------------------------------------------*/
  2068.  next_tab_col = find_next_tab_col(current_col);
  2069. /*---------------------------------------------------------------------*/
  2070. /* If no next tab column, stay where we are and return...              */
  2071. /*---------------------------------------------------------------------*/
  2072.  if (next_tab_col == 0)
  2073.    {
  2074. #ifdef TRACE
  2075.     trace_return();
  2076. #endif
  2077.     return(RC_OK);
  2078.    }
  2079. /*---------------------------------------------------------------------*/
  2080. /* Check for going past end of line - max_line_length                  */
  2081. /*---------------------------------------------------------------------*/
  2082.  if (next_tab_col > max_line_length)
  2083.    {
  2084. #ifdef TRACE
  2085.     trace_return();
  2086. #endif
  2087.     return(RC_TRUNCATED);
  2088.    }
  2089. /*---------------------------------------------------------------------*/
  2090. /* For all windows, if the new cursor position does not exceed the     */
  2091. /* right edge, move there.                                             */
  2092. /*---------------------------------------------------------------------*/
  2093.  next_tab_col--;                               /* zero base the column */
  2094.  
  2095. #ifdef VERSHIFT
  2096.  rc = execute_move_cursor(next_tab_col);
  2097. #else
  2098.  calculate_new_column(x,CURRENT_VIEW->verify_col,next_tab_col,&new_screen_col,&new_verify_col);
  2099.  if (CURRENT_VIEW->verify_col != new_verify_col
  2100.  &&  CURRENT_VIEW->current_window == WINDOW_MAIN)
  2101.    {
  2102.     CURRENT_VIEW->verify_col = new_verify_col;
  2103.     build_current_screen(); 
  2104.     display_current_screen();
  2105.    }
  2106.  wmove(CURRENT_WINDOW,y,new_screen_col);
  2107. #endif
  2108.  
  2109. #ifdef TRACE
  2110.  trace_return();
  2111. #endif
  2112.  return(rc);
  2113. }
  2114. /*man-start*********************************************************************
  2115. COMMAND
  2116.      sos tabfieldb - move cursor to previous enterable field
  2117.  
  2118. SYNTAX
  2119.      SOS TABFIELDB
  2120.  
  2121. DESCRIPTION
  2122.      The SOS TABFIELDB command causes the cursor to move to the first
  2123.      column of the current enterable field. If the cursor is already
  2124.      in the first column of the current field the cursor moves to the
  2125.      first column of the previous enterable field on the screen. 
  2126.      This command is intended to mimic the behavior of the SHIFT-TAB 
  2127.      key on a 3270 terminal.
  2128.  
  2129. COMPATIBILITY
  2130.      XEDIT: N/A
  2131.      KEDIT: Compatible.
  2132.  
  2133. SEE ALSO
  2134.      SOS TABFIELDF
  2135.  
  2136. STATUS
  2137.      Complete.
  2138. **man-end**********************************************************************/
  2139. #ifdef PROTO
  2140. short Sos_tabfieldb(CHARTYPE *params)
  2141. #else
  2142. short Sos_tabfieldb(params)
  2143. CHARTYPE *params;
  2144. #endif
  2145. /***********************************************************************/
  2146. {
  2147. /*-------------------------- external data ----------------------------*/
  2148.  extern short prefix_width;
  2149. /*--------------------------- local data ------------------------------*/
  2150.  short rc=RC_OK;
  2151.  long save_where=0L,where=0L,what_current=0L,what_other=0L;
  2152.  unsigned short y=0,x=0,left_col=0;
  2153.  bool stay_in_current_field=FALSE;
  2154. /*--------------------------- processing ------------------------------*/
  2155. #ifdef TRACE
  2156.  trace_function("commsos.c: Sos_tabfieldb");
  2157. #endif
  2158. /*---------------------------------------------------------------------*/
  2159. /* Determine if the cursor is in the left-most column of the current   */
  2160. /* field...                                                            */
  2161. /*---------------------------------------------------------------------*/
  2162.  getyx(CURRENT_WINDOW,y,x);
  2163.  switch(CURRENT_VIEW->current_window)
  2164.    {
  2165.     case WINDOW_MAIN:
  2166.     case WINDOW_COMMAND:
  2167.          if (x != left_col)
  2168.             stay_in_current_field = TRUE;
  2169.          break;
  2170.     case WINDOW_PREFIX:
  2171.          if ((CURRENT_VIEW->prefix&PREFIX_LOCATION_MASK) == PREFIX_RIGHT
  2172.          &&  prefix_width != PREFIX_WIDTH)
  2173.             left_col = 1;
  2174.          else
  2175.             left_col = 0;
  2176.          if (x != left_col)
  2177.             stay_in_current_field = TRUE;
  2178.          break;
  2179.    }
  2180. /*---------------------------------------------------------------------*/
  2181. /* If the cursor was not in the left-most column of the current field, */
  2182. /* move it there now...                                                */
  2183. /*---------------------------------------------------------------------*/
  2184.  if (stay_in_current_field)
  2185.    {
  2186.     wmove(CURRENT_WINDOW,y,left_col);
  2187. #ifdef TRACE
  2188.     trace_return();
  2189. #endif
  2190.     return(rc);
  2191.    }
  2192. /*---------------------------------------------------------------------*/
  2193. /* ... otherwise determine which is the previous enterable filed and   */
  2194. /* move the cursor there.                                              */
  2195. /*---------------------------------------------------------------------*/
  2196.  save_where = where = where_now();
  2197.  what_current = what_current_now();
  2198.  what_other = what_other_now();
  2199.  while(1)
  2200.    {
  2201.     where = where_before(where,what_current,what_other);
  2202.     if (where == save_where)
  2203.        break;
  2204.     if (enterable_field(where))
  2205.        break;
  2206.    }
  2207. /*---------------------------------------------------------------------*/
  2208. /* If we can't go anywhere, stay where we are...                       */
  2209. /*---------------------------------------------------------------------*/
  2210.  if (where == save_where)
  2211.    {
  2212. #ifdef TRACE
  2213.     trace_return();
  2214. #endif
  2215.     return(rc);
  2216.    }
  2217.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  2218.  rc = go_to_new_field(save_where,where);
  2219.  pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  2220. #ifdef TRACE
  2221.  trace_return();
  2222. #endif
  2223.  return(rc);
  2224. }
  2225. /*man-start*********************************************************************
  2226. COMMAND
  2227.      sos tabfieldf - move cursor to next enterable field
  2228.  
  2229. SYNTAX
  2230.      SOS TABFIELDf
  2231.  
  2232. DESCRIPTION
  2233.      The SOS TABFIELDF command causes the cursor to move to the next 
  2234.      enterable field on the screen. This command is intended to
  2235.      mimic the behavior of the TAB key on a 3270 terminal.
  2236.  
  2237. COMPATIBILITY
  2238.      XEDIT: N/A
  2239.      KEDIT: Compatible.
  2240.  
  2241. SEE ALSO
  2242.      SOS TABFIELDB
  2243.  
  2244. STATUS
  2245.      Complete.
  2246. **man-end**********************************************************************/
  2247. #ifdef PROTO
  2248. short Sos_tabfieldf(CHARTYPE *params)
  2249. #else
  2250. short Sos_tabfieldf(params)
  2251. CHARTYPE *params;
  2252. #endif
  2253. /***********************************************************************/
  2254. {
  2255. /*-------------------------- external data ----------------------------*/
  2256. /*--------------------------- local data ------------------------------*/
  2257.  short rc=RC_OK;
  2258.  long save_where=0L,where=0L,what_current=0L,what_other=0L;
  2259. /*--------------------------- processing ------------------------------*/
  2260. #ifdef TRACE
  2261.  trace_function("commsos.c: Sos_tabfieldf");
  2262. #endif
  2263.  save_where = where = where_now();
  2264.  what_current = what_current_now();
  2265.  what_other = what_other_now();
  2266.  while(1)
  2267.    {
  2268.     where = where_next(where,what_current,what_other);
  2269.     if (where == save_where)
  2270.        break;
  2271.     if (enterable_field(where))
  2272.        break;
  2273.    }
  2274. /*---------------------------------------------------------------------*/
  2275. /* If we can't go anywhere, stay where we are...                       */
  2276. /*---------------------------------------------------------------------*/
  2277.  if (where == save_where)
  2278.    {
  2279. #ifdef TRACE
  2280.     trace_return();
  2281. #endif
  2282.     return(rc);
  2283.    }
  2284.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  2285.  rc = go_to_new_field(save_where,where);
  2286.  pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  2287. #ifdef TRACE
  2288.  trace_return();
  2289. #endif
  2290.  return(rc);
  2291. }
  2292. /*man-start*********************************************************************
  2293. COMMAND
  2294.      sos tabwordb - move cursor to beginning of previous word
  2295.  
  2296. SYNTAX
  2297.      SOS TABWORDB
  2298.  
  2299. DESCRIPTION
  2300.      The SOS TABWORDB command causes the cursor to move to the first character
  2301.      of the word to the left or to the start of the line if no more
  2302.      words precede.
  2303.      If the resulting column is beyond the left hand edge of the 
  2304.      FILEAREA, the window will scroll half a window.
  2305.  
  2306. COMPATIBILITY
  2307.      XEDIT: N/A
  2308.      KEDIT: Compatible.
  2309.  
  2310. SEE ALSO
  2311.      SOS TABWORDF
  2312.  
  2313. STATUS
  2314.      Complete.
  2315. **man-end**********************************************************************/
  2316. #ifdef PROTO
  2317. short Sos_tabwordb(CHARTYPE *params)
  2318. #else
  2319. short Sos_tabwordb(params)
  2320. CHARTYPE *params;
  2321. #endif
  2322. /***********************************************************************/
  2323. {
  2324. /*-------------------------- external data ----------------------------*/
  2325.  extern CHARTYPE *rec;
  2326.  extern LENGTHTYPE rec_len;
  2327.  extern CHARTYPE *cmd_rec;
  2328.  extern unsigned short cmd_rec_len;
  2329. /*--------------------------- local data ------------------------------*/
  2330.  unsigned short x=0,y=0;
  2331.  short start_word_col=0;
  2332.  unsigned short word_break=0;
  2333.  CHARTYPE *temp_rec=NULL;
  2334.  register short i=0;
  2335.  short num_cols=0,col_pos=0,left_col=0;
  2336.  COLTYPE new_screen_col=0;
  2337.  LENGTHTYPE new_verify_col=0;
  2338.  short rc=RC_OK;
  2339. /*--------------------------- processing ------------------------------*/
  2340. #ifdef TRACE
  2341.  trace_function("commsos.c: Sos_tabwordb");
  2342. #endif
  2343. /*---------------------------------------------------------------------*/
  2344. /* This function is not applicable to the PREFIX window.               */
  2345. /*---------------------------------------------------------------------*/
  2346.  getyx(CURRENT_WINDOW,y,x);
  2347.  switch(CURRENT_VIEW->current_window)
  2348.    {
  2349.     case WINDOW_PREFIX:
  2350.          display_error(38,(CHARTYPE *)"",FALSE);
  2351. #ifdef TRACE
  2352.          trace_return();
  2353. #endif
  2354.          return(RC_INVALID_ENVIRON);
  2355.          break;
  2356.     case WINDOW_MAIN:
  2357.          temp_rec = rec;
  2358.          left_col = CURRENT_VIEW->verify_col-1;
  2359.          break;
  2360.     case WINDOW_COMMAND:
  2361.          temp_rec = (CHARTYPE *)cmd_rec;
  2362.          left_col = 0;
  2363.          break;
  2364.    }
  2365. /*---------------------------------------------------------------------*/
  2366. /* Determine the start of the prior word, or go to the start of the    */
  2367. /* line if already at or before beginning of prior word.               */
  2368. /*---------------------------------------------------------------------*/
  2369.  word_break = 0;
  2370.  start_word_col = (-1);
  2371.  for (i=left_col+x;i>0;i--)
  2372.    {
  2373.     switch(word_break)
  2374.       {
  2375.        case 0:  /* still in current word */
  2376.             if (*(temp_rec+i) == ' ')
  2377.                word_break++;
  2378.             break;
  2379.        case 1:  /* in first blank space */
  2380.             if (*(temp_rec+i) != ' ')
  2381.                word_break++;
  2382.             break;
  2383.        case 2:  /* in previous word */
  2384.             if (*(temp_rec+i) == ' ')
  2385.               {
  2386.                start_word_col = i+1;
  2387.                word_break++;
  2388.               }
  2389.             break;
  2390.        default: /* should not get here */
  2391.             break;
  2392.       }
  2393.     if (word_break == 3)
  2394.        break;
  2395.    }
  2396.  if (start_word_col == (-1))
  2397.     start_word_col = 0;
  2398.  
  2399. #ifdef VERSHIFT
  2400.  rc = execute_move_cursor(start_word_col);
  2401. #else
  2402.  calculate_new_column(x,CURRENT_VIEW->verify_col,start_word_col,&new_screen_col,&new_verify_col);
  2403.  if (CURRENT_VIEW->verify_col != new_verify_col
  2404.  &&  CURRENT_VIEW->current_window == WINDOW_MAIN)
  2405.    {
  2406.     CURRENT_VIEW->verify_col = new_verify_col;
  2407.     build_current_screen(); 
  2408.     display_current_screen();
  2409.    }
  2410.  wmove(CURRENT_WINDOW,y,new_screen_col);
  2411. #endif
  2412.  
  2413. #ifdef TRACE
  2414.  trace_return();
  2415. #endif
  2416.  return(rc);
  2417. }
  2418. /*man-start*********************************************************************
  2419. COMMAND
  2420.      sos tabwordf - move cursor to start of next word
  2421.  
  2422. SYNTAX
  2423.      SOS TABWORDf
  2424.  
  2425. DESCRIPTION
  2426.      The SOS TABWORDF command causes the cursor to move to the first character
  2427.      of the next word to the right or to the end of the line if no more
  2428.      words follow.
  2429.      If the resulting column is beyond the right hand edge of the
  2430.      FILEAREA, the window will scroll half a window.
  2431.  
  2432. COMPATIBILITY
  2433.      XEDIT: N/A
  2434.      KEDIT: Compatible.
  2435.  
  2436. SEE ALSO
  2437.      SOS TABWORDB
  2438.  
  2439. STATUS
  2440.      Complete.
  2441. **man-end**********************************************************************/
  2442. #ifdef PROTO
  2443. short Sos_tabwordf(CHARTYPE *params)
  2444. #else
  2445. short Sos_tabwordf(params)
  2446. CHARTYPE *params;
  2447. #endif
  2448. /***********************************************************************/
  2449. {
  2450. /*-------------------------- external data ----------------------------*/
  2451.  extern CHARTYPE *rec;
  2452.  extern LENGTHTYPE rec_len;
  2453.  extern CHARTYPE *cmd_rec;
  2454.  extern unsigned short cmd_rec_len;
  2455. /*--------------------------- local data ------------------------------*/
  2456.  unsigned short x=0,y=0,temp_rec_len=0,num_cols=0;
  2457.  short start_word_col=0,left_col=0;
  2458.  bool word_break=FALSE;
  2459.  CHARTYPE *temp_rec=NULL;
  2460.  register short i=0;
  2461.  COLTYPE new_screen_col=0;
  2462.  LENGTHTYPE new_verify_col=0;
  2463.  short rc=RC_OK;
  2464. /*--------------------------- processing ------------------------------*/
  2465. #ifdef TRACE
  2466.  trace_function("commsos.c: Sos_tabwordf");
  2467. #endif
  2468. /*---------------------------------------------------------------------*/
  2469. /* This function is not applicable to the PREFIX window.               */
  2470. /*---------------------------------------------------------------------*/
  2471.  getyx(CURRENT_WINDOW,y,x);
  2472.  switch(CURRENT_VIEW->current_window)
  2473.    {
  2474.     case WINDOW_PREFIX:
  2475.          display_error(38,(CHARTYPE *)"",FALSE);
  2476. #ifdef TRACE
  2477.          trace_return();
  2478. #endif
  2479.          return(RC_INVALID_ENVIRON);
  2480.          break;
  2481.     case WINDOW_MAIN:
  2482.          temp_rec = rec;
  2483.          temp_rec_len = rec_len;
  2484.          left_col = CURRENT_VIEW->verify_col-1;
  2485.          break;
  2486.     case WINDOW_COMMAND:
  2487.          temp_rec = (CHARTYPE *)cmd_rec;
  2488.          temp_rec_len = cmd_rec_len;
  2489.          left_col = 0;
  2490.          break;
  2491.    }
  2492. /*---------------------------------------------------------------------*/
  2493. /* If we are after the last column of the line, then just ignore the   */
  2494. /* command and leave the cursor where it is.                           */
  2495. /*---------------------------------------------------------------------*/
  2496.  if ((x + left_col) > temp_rec_len)
  2497.    {
  2498. #ifdef TRACE
  2499.     trace_return();
  2500. #endif
  2501.     return(RC_OK);
  2502.    }
  2503. /*---------------------------------------------------------------------*/
  2504. /* Determine the start of the next word, or go to the end of the line  */
  2505. /* if already at or past beginning of last word.                       */
  2506. /*---------------------------------------------------------------------*/
  2507.  word_break = FALSE;
  2508.  start_word_col = (-1);
  2509.  for (i=left_col+x;i<temp_rec_len;i++)
  2510.    {
  2511.     if (*(temp_rec+i) == ' ')
  2512.        word_break = TRUE;
  2513.     else
  2514.       {
  2515.        if (word_break)
  2516.          {
  2517.           start_word_col = i;
  2518.           break;
  2519.          }
  2520.       }
  2521.    }
  2522.  if (start_word_col == (-1))
  2523.     start_word_col = temp_rec_len;
  2524.  
  2525. #ifdef VERSHIFT
  2526.  rc = execute_move_cursor(start_word_col);
  2527. #else
  2528.  calculate_new_column(x,CURRENT_VIEW->verify_col,start_word_col,&new_screen_col,&new_verify_col);
  2529.  if (CURRENT_VIEW->verify_col != new_verify_col
  2530.  &&  CURRENT_VIEW->current_window == WINDOW_MAIN)
  2531.    {
  2532.     CURRENT_VIEW->verify_col = new_verify_col;
  2533.     build_current_screen(); 
  2534.     display_current_screen();
  2535.    }
  2536.  wmove(CURRENT_WINDOW,y,new_screen_col);
  2537. #endif
  2538.  
  2539. #ifdef TRACE
  2540.  trace_return();
  2541. #endif
  2542.  return(rc);
  2543. }
  2544. /*man-start*********************************************************************
  2545. COMMAND
  2546.      sos topedge - move cursor to top edge of filearea
  2547.  
  2548. SYNTAX
  2549.      SOS TOPEdge
  2550.  
  2551. DESCRIPTION
  2552.      The SOS TOPEDGE command moves the cursor to the first
  2553.      enterable line in the FILEAREA or PREFIX area. If the cursor
  2554.      is on the command line, the cursor moves to the first 
  2555.      enterable line of the FILEAREA.
  2556.  
  2557. COMPATIBILITY
  2558.      XEDIT: N/A
  2559.      KEDIT: Comaptible.
  2560.  
  2561. SEE ALSO
  2562.      SOS BOTTOMEDGE
  2563.  
  2564. STATUS
  2565.      Complete.
  2566. **man-end**********************************************************************/
  2567. #ifdef PROTO
  2568. short Sos_topedge(CHARTYPE *params)
  2569. #else
  2570. short Sos_topedge(params)
  2571. CHARTYPE *params;
  2572. #endif
  2573. /***********************************************************************/
  2574. {
  2575. /*-------------------------- external data ----------------------------*/
  2576. /*--------------------------- local data ------------------------------*/
  2577.  short rc=RC_OK;
  2578.  unsigned short y=0,x=0,row=0;
  2579. /*--------------------------- processing ------------------------------*/
  2580. #ifdef TRACE
  2581.  trace_function("commsos.c: Sos_topedge");
  2582. #endif
  2583.  getyx(CURRENT_WINDOW,y,x);
  2584. /*---------------------------------------------------------------------*/
  2585. /* Get the last enterable row. If an error, stay where we are...       */
  2586. /*---------------------------------------------------------------------*/
  2587.  if (find_first_focus_line(&row) != RC_OK)
  2588.    {
  2589. #ifdef TRACE
  2590.     trace_return();
  2591. #endif
  2592.     return(rc);
  2593.    }
  2594. /*---------------------------------------------------------------------*/
  2595. /* For each window determine what needs to be done...                  */
  2596. /*---------------------------------------------------------------------*/
  2597.  switch(CURRENT_VIEW->current_window)
  2598.    {
  2599.     case WINDOW_COMMAND:
  2600.          if ((CURRENT_VIEW->prefix&PREFIX_LOCATION_MASK) != PREFIX_LEFT)
  2601.             x += PREFIX_WIDTH;
  2602.          CURRENT_VIEW->focus_line = CURRENT_SCREEN.sl[row].line_number;
  2603.          pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  2604.          CURRENT_VIEW->current_window = WINDOW_MAIN;
  2605.          wmove(CURRENT_WINDOW,row,x);
  2606.          break;
  2607.     case WINDOW_MAIN:
  2608.     case WINDOW_PREFIX:
  2609.             if (row != y)                            /* different rows */
  2610.               {
  2611.                post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  2612.                CURRENT_VIEW->focus_line = CURRENT_SCREEN.sl[row].line_number;
  2613.                pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  2614.                wmove(CURRENT_WINDOW,row,x);
  2615.               }
  2616.             break;
  2617.    }
  2618. #ifdef TRACE
  2619.  trace_return();
  2620. #endif
  2621.  return(rc);
  2622. }
  2623. /*man-start*********************************************************************
  2624. COMMAND
  2625.      sos undo - undo changes to the current line
  2626.  
  2627. SYNTAX
  2628.      SOS UNDO
  2629.  
  2630. DESCRIPTION
  2631.      The SOS UNDO command causes the contents of the focus line (or the
  2632.      command line) to be reset to the contents before the cursor was
  2633.      positioned there.
  2634.  
  2635. COMPATIBILITY
  2636.      XEDIT: N/A
  2637.      KEDIT: Compatible. 
  2638.  
  2639. STATUS
  2640.      Complete.
  2641. **man-end**********************************************************************/
  2642. #ifdef PROTO
  2643. short Sos_undo(CHARTYPE *params)
  2644. #else
  2645. short Sos_undo(params)
  2646. CHARTYPE *params;
  2647. #endif
  2648. /***********************************************************************/
  2649. {
  2650. /*-------------------------- external data ----------------------------*/
  2651.  extern CHARTYPE *cmd_rec;
  2652.  extern unsigned short cmd_rec_len;
  2653.  extern CHARTYPE *pre_rec;
  2654.  extern unsigned short pre_rec_len;
  2655.  extern bool prefix_changed;
  2656. /*--------------------------- local data ------------------------------*/
  2657.  unsigned short x=0,y=0;
  2658. /*--------------------------- processing ------------------------------*/
  2659. #ifdef TRACE
  2660.  trace_function("commsos.c: Sos_undo");
  2661. #endif
  2662. /*---------------------------------------------------------------------*/
  2663. /* No arguments are allowed; error if any are present.                 */
  2664. /*---------------------------------------------------------------------*/
  2665.  if (strcmp(params,"") != 0)
  2666.    {
  2667.     display_error(1,(CHARTYPE *)params,FALSE);
  2668. #ifdef TRACE
  2669.     trace_return();
  2670. #endif
  2671.     return(RC_INVALID_OPERAND);
  2672.    }
  2673.  switch (CURRENT_VIEW->current_window)
  2674.    {
  2675.     case WINDOW_MAIN:
  2676.          pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  2677.          build_current_screen(); 
  2678.          display_current_screen();
  2679.          break;
  2680.     case WINDOW_COMMAND:
  2681.          memset(cmd_rec,' ',COLS);
  2682.          cmd_rec_len = 0;
  2683.          wmove(CURRENT_WINDOW,0,0);
  2684.          my_wclrtoeol(CURRENT_WINDOW);
  2685.          break;
  2686.     case WINDOW_PREFIX:
  2687.          prefix_changed = TRUE;
  2688.          memset(pre_rec,' ',PREFIX_WIDTH);
  2689.          pre_rec_len = 0;
  2690.          getyx(CURRENT_WINDOW,y,x);
  2691.          wmove(CURRENT_WINDOW,y,0);
  2692.          my_wclrtoeol(CURRENT_WINDOW);
  2693.          break;
  2694.     default:
  2695.          break;
  2696.    }
  2697. #ifdef TRACE
  2698.  trace_return();
  2699. #endif
  2700.  return(RC_OK);
  2701. }
  2702.